<script>
    var nameList = ['张三', '李四', '王五', '张六'];

    var newList = nameList.filter(function (item, index) {
        // 返回符合条件的成员
        return item === '张三';
    })
    console.log(newList);


    var newList2 = nameList.filter(function (item, index) {
        return item.includes('张');
    });
    console.log('newList2', newList2);


    var nameList2 = [
        { name: '张三', age: 18 },
        { name: '李四', age: 20 },
        { name: '王五', age: 30 },
        { name: '张六', age: 22 },
    ];
    var newList3 = nameList2.filter(function (item, index) {
        return item.age > 20;
    })
    console.log('newList3', newList3);
</script>